#ifndef Timer_h__
#define Timer_h__

#include "Common.h"
#include <windows.h>
#include <mmsystem.h>


class Timer
{
public:
	Timer(int timeout=0) : m_currnet(0), m_timeout(timeout)
	{

	}

	~Timer(void)
	{

	}

	bool passed()
	{
		return m_currnet >= m_timeout;
	}

	void reset()
	{
		m_currnet = 0;
	}

	void update(uint32 timeElapse)
	{
		m_currnet += timeElapse;
	}

	int timeout() const
	{
		return m_timeout;
	}

	void setTimeout(int timeout)
	{
		m_timeout = timeout;
	}

private:
	int m_timeout;
	int m_currnet;

};

inline
uint32 getMsTime()
{
	return timeGetTime();
}

inline 
void sleep(uint32 misec)
{
	boost::this_thread::sleep(boost::posix_time::milliseconds(misec));
}

#endif // Timer_h__

